/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phd.dupenois.changeidentifiers.utils;

import java.awt.geom.GeneralPath;
import phd.dupenois.changeidentifiers.footprints.Footprint;
import uk.co.dupenois.geometry.Coordinate;

/**
 *
 * @author mpd209
 */
public class BoundingBox {
    private Coordinate bottomLeft;
    private Coordinate topLeft;
    private Coordinate topRight;
    private Coordinate bottomRight;
    public BoundingBox(Coordinate bottomLeft, Coordinate topLeft,
            Coordinate topRight, Coordinate bottomRight){
        this.bottomLeft = bottomLeft;
        this.topLeft = topLeft;
        this.topRight = topRight;
        this.bottomRight = bottomRight;
    }

    public Coordinate getCenter() {
        double x = this.topRight.getX()-this.topLeft.getX();
        double y = this.topRight.getY()-this.bottomRight.getY();
        return new Coordinate(x, y);
    }

    /**
     * @return the bottomLeft
     */
    public Coordinate getBottomLeft() {
        return bottomLeft;
    }

    /**
     * @return the topLeft
     */
    public Coordinate getTopLeft() {
        return topLeft;
    }

    /**
     * @return the topRight
     */
    public Coordinate getTopRight() {
        return topRight;
    }

    /**
     * @return the bottomRight
     */
    public Coordinate getBottomRight() {
        return bottomRight;
    }

    public Footprint toFootprint(){
        Footprint footprint = new Footprint();
        footprint.addLine(this.bottomLeft, this.topLeft);
        footprint.addLine(this.topLeft, this.topRight);
        footprint.addLine(this.topRight, this.bottomRight);
        footprint.addLine(this.bottomRight, this.bottomLeft);
        return footprint;
    }
    public GeneralPath toGeneralPath(){
        return toFootprint().constructGeneralPath();
    }
}
